layui.define(['table', 'form', 'upload', 'admin'], function (exports) {
    var $ = layui.$
        , table = layui.table
        , form = layui.form
        , upload = layui.upload
        , admin = layui.admin;

    //
    table.render({
        elem: '#LAY-order-manage'
        , url: '/admin/order/getuserOrderlist?uid=' + $('#userId').val()
        , totalRow: true
        , cols: [[
            {field: 'id', width: 100, title: 'ID', sort: true, fixed: 'left'}
            , {field: 'order_no', title: '订单号', width: 200, totalRowText: '合计'}
            , {
                field: '', width: 120, title: '订单类型', templet: function (d) {
                    if (d.type == '') {
                        return '';
                    }
                    switch (d.type) {
                        case 0:
                            return "钻石充值";
                        case 1:
                            return "开通贵族-vip";
                        default:
                            return "其他";
                    }
                }
            }
            , {field: 'amount', title: '订单金额/元', width: 110, totalRow: true}
            , {field: 'pay_amount', title: '应付金额/元', width: 110, totalRow: true}
            , {field: 'gold', title: '购买宝石', width: 90, totalRow: true}
            , {field: 'gold_added', title: '赠送宝石', width: 90, totalRow: true}
            , {field: 'out_trade_no', minWidth: 160, title: '支付单号'}
            , {
                field: 'pay_channel', width: 90, title: '支付渠道', templet: function (d) {
                    if (d.pay_channel == '') {
                        return '';
                    }
                    switch (d.pay_channel) {
                        case 1:
                            return "微信支付";
                        case 2:
                            return "支付宝";
                        case 3:
                            return "Apple PayY";
                        case 5:
                            return "管理员";
                        default:
                            return "其他";
                    }
                }
            }
            , {
                field: 'pay_status', width: 100, title: '支付状态', templet: function (d) {
                    switch (d.pay_status) {
                        case 0:
                            return '<span class="layui-badge layui-bg-orange">等待支付</span>';
                        case 1:
                            return '<span class="layui-badge layui-bg-green">支付成功</span>';
                        case 2:
                            return '<span class="layui-badge layui-bg-black">支付取消</span>';
                        case 3:
                            return '<span class="layui-badge layui-bg-red">支付失败</span>';
                        default:
                            return "";
                    }
                }
            }
            , {field: 'create_time', width: 170, title: '下单时间'}
        ]]
        , page: true
        , limit: 20
        , height: 'full-140'
        , text: '对不起，加载出现异常！'
        , even: true
    });

    exports('user_order', {})
});